package com.itheima.udp;

import java.io.IOException;
import java.net.*;

public class Send {
    public static void main(String[] args) throws IOException {
        //创建一个DatagramSocket对象来进行发送;
        DatagramSocket datagramSocket = new DatagramSocket();
        String str = "HelloWord";
        byte[] bytes = str.getBytes();
        //创建一个DatagramPacket对象来封装数据;
        InetAddress byName = InetAddress.getByName("127.0.0.1");
        DatagramPacket datagramPacket = new DatagramPacket(bytes, bytes.length, byName,4444);
        datagramSocket.send(datagramPacket);
        datagramSocket.close();
    }
}
